<?php
$title="Quran By Subject| ايات القران مفهرسه حسب المواضيع";
?>
<?php include 'header.php'; ?>
<?php include 'settings.php'; ?>
<script src="http://listjs.com/no-cdn/list.js"></script>



<div id="users">
  <input class="search" placeholder="Search" />
  


<?php



$con=mysqli_connect($host,$dbuserR,$dbpassR,$dbname);

//$con=mysqli_connect("localhost","quran","quran","Quran");
// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}


$result=mysqli_query($con,"select * from Category where ParentIndex='1' and Banned=0 order by Description");

while($row = mysqli_fetch_array($result)) 
{
//echo "<a class='anchor' name='".$row['Description']."'>".$row['Description']."</a>";
echo "<br><a href='#".$row['Description']."'>".$row['Description']."</a>";

}




$result=mysqli_query($con,"select Category.ParentIndex as parenti,Description,(case Category.ParentIndex when '' then  (select Description from Category where CIndex='319aa7be-4ecc-11e4-9410-000c29db8d9b' ) else (select Description from Category where CIndex=parenti) end) as parentname, Category.CIndex,Category.Description,(select count(CategoryAya.CategoryIndex) from CategoryAya where CategoryAya.Banned=0 and Category.CIndex=CategoryAya.CategoryIndex ) as countrow from Category where Banned=0 and Category.ParentIndex<>1 order by parentname ASC ,countrow DESC");

echo "<ul class='list'>";
while($row = mysqli_fetch_array($result)) 
{


if ($lastcat<>$row['parentname'])
{
$lastcat=$row['parentname'];
echo "<a class='anchor' name='".$row['parentname']."'>".$row['parentname']."</a>";
echo "<h2>".$lastcat."</h2>";
}
echo    "\n<li>";
echo ("<a href='category.php?category=".$row['CIndex']."'><h3 class='name'>");
echo $row['Description']." (".$row['countrow'].")</h3></a>";
echo "</li>\n";
}
echo "</ul>";



















?> 

</div>
<Script>
var options = {
  valueNames: [ 'name' ]
};

var userList = new List('users', options);
</Script>
<?php include 'footer.php'; ?>
